import { _decorator, color, Color, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
import { TreaIng } from '../entity/TreaIng';
import TreaApi from '../api/TreaApi';
import { Rombaw } from './Rombaw';
import { EventManager } from '../event/EventManager';
import { nftdata, PurchaseConfig, PurchaseType } from "../settings/const";
import { RombawIng } from '../entity/RombawIng';
import ResManager from '../common/ResManager';
const { ccclass, property } = _decorator;

@ccclass('BackpackItem')
export class BackpackItem extends Component {
  
    /**当前物品数量 */
    @property(Label)
    num: Label
    /**当前物品图片 */
    @property(Sprite)
    imgUrl: Sprite
    /**当前物品信息 */
    rom: RombawIng


    start() {
        this.node.on(Node.EventType.TOUCH_END, this.backpackItemBtn, this)
    }

    backpackItemBtn() {
        EventManager.instance.emit(EventManager.EventType.romList, this.rom)
    }


    async setData(rom: RombawIng) {
        this.rom = rom
      
        this.num.string = String(this.rom.num)
        this.imgUrl.spriteFrame = await rom.getRombawIngImg()
    }
}


